//个人中心控制器
app.controller("mine", ["$scope", "$rootScope", "$state", "$http", function($scope, $rootScope, $state, $http) {
		$rootScope.page.footer = 'mine';
		$rootScope.page.showfooter = true;
		scrollTo(0, 0);
		$rootScope.findshopcarNum()
		$rootScope.record()
		var userID = localStorage.getItem("user_ID")
		var token = localStorage.getItem("token")
		$scope.mypersonal = function() {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.personal")
			}
		}
		$scope.allOrder = function() {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.myOrder")
			}
		}
		$scope.afterSer = function() {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.after_sales")
			}
		}
		$scope.waitCom = function() {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.wait_comment")
			}
		}
		$scope.waitPay = function() {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.wait_pay")
			}
		}
		$scope.toMywallet = function() {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.mywallet")
			}
		}
		$scope.toColl = function() {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.collection")
			}
		}

		$scope.toFoot = function() {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.footprint")
			}
		}

		$scope.toJointuan = function(p) {
			if(!localStorage.getItem("user_ID")) {
				$rootScope.register()
			} else {
				$state.go("main.tuxedo", {
					is_p: p
				})
			}
		}
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Member/userinfo',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: userID,
				token: token
			}
		}).success(function(data) {
			console.log(data)
			if(data["status"] != 1) {
				$rootScope.login(data)
			}
			if(data["status"] == 1) {
				$scope.mine = data["list"]
				$scope.balance = data["list"]["balance"] //余额
				$scope.bean = data["list"]["bean"] //乐豆
				$scope.img = data["list"]["avatar"] //头像
				$scope.is_p = data["list"]["is_p"]
			}
		})
	}])
	//足迹
app.controller("footprint", ["$scope", "$rootScope", "$state", "$http", function($scope, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'mine';
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Member/footprint',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token")
		}
	}).success(function(data) {
		$rootScope.login(data)
		$scope.toInfo = function(id, type, Type) {
			if(type == 1) {
				$state.go("main.routeInfo", {
					Id: id
				})
			} else {
				if(type == 2 && Type == 1) {
					$state.go("main.projectInfo", {
						Id: id
					})
				} else {
					$state.go("main.newprojectInfo", {
						Id: id
					})
				}

			}
		}
		if(!data["list"]) {
			$scope.page.rongcuo = true
		} else {
			$scope.page.rongcuo = false
			$scope.footprint = data["list"]
		}
	})
	setTimeout(function() {
		//滑动删除
		for(var i = 0; i < $(".shopCarMove").length; i++) {
			$(".shopCarMove").eq(i).attr("dataIndex", i);
		}
		shopCarRemove('.shopCarMove');

		function shopCarRemove(box) {
			var boxList = $(box);
			var boxHeight = boxList.outerHeight();
			var btnList = null;
			var btnWidth = null;
			boxList.on("touchstart", function(e) {
				btnList = $('.shopCarDelete');
				btnWidth = -btnList.outerWidth();
				this.startX = e.originalEvent.targetTouches[0].clientX;
				this.startY = e.originalEvent.targetTouches[0].clientY;
			});
			boxList.on("touchend", function(e) {
				var dataIndex = $(this).attr("dataIndex");
				this.MissX = this.startX - e.originalEvent.changedTouches[0].clientX;
				this.MissY = this.startY - e.originalEvent.changedTouches[0].clientY;
				if(Math.abs(this.MissY) < boxHeight && this.MissX > 25) {
					btnList.eq(dataIndex).stop(true, true).animate({
						"right": btnWidth
					}, 80);
					$(this).stop(true, true).animate({
						"right": -btnWidth
					}, 80);
					//				$(this).parent().siblings().find(".shopCarMove").stop(true,true).animate({"right":0},250);
					//				$(this).parent().siblings().find(".shopCarDelete").stop(true,true).animate({"right":btnWidth},250);
				} else if(Math.abs(this.MissY) < boxHeight && this.MissX < -25) {
					btnList.eq(dataIndex).stop(true, true).animate({
						"right": btnWidth
					}, 80);
					$(this).stop(true, true).animate({
						"right": "0px"
					}, 80);
				}
			});
			//点击删除
			$(".shopCarDelete").click(function() {
				var shopCarlistLength = $(this).parents(".footprint_list").find(".order_list_com").length; //每个商铺商品的长度
				if(shopCarlistLength > 1) {
					$(this).parent().parent().remove();
				} else {
					$(this).parents(".footprint_list").remove();
				}
				if($(".order_list_com").length == 0) {
					$scope.page.rongcuo = true;
				}
				var delsku = $(this).attr("sku")
				$http({
						method: 'post',
						url: '' + $rootScope.Location + 'Member/del_history',
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						data: {
							user_Id: localStorage.getItem("user_ID"),
							token: localStorage.getItem("token"),
							history_Id: "," + delsku
						},
					}).success(function(data) {
						console.log(data)
					})
					//			if($(".shopCarlist").length == 0) {
					//				$scope.page.rongcuo = true;  //容错展示
					//			}
					//			var goodsSku = $(this).parent().parent().attr("sku");
					//			$http.jsonp("http://" + $rootScope.Location + "/cart/deleteCart?callback=JSON_CALLBACK&skuCode=" + goodsSku + "").success(function(data) {
					//			})
			})
		}
	}, 1000)
}])

//收藏
app.controller("collection", ["$scope", "$rootScope", "$state", "$http", function($scope, $rootScope, $state, $http) {
		$rootScope.page.showfooter = true
		$rootScope.page.footer = 'mine';
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Member/collect',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token")
			}
		}).success(function(data) {
			console.log(data)
			$rootScope.login(data)
			$scope.toInfo = function(id, type, Type) {
				if(type == 1) {
					$state.go("main.routeInfo", {
						Id: id
					})
				} else {
					if(type == 2 && Type == 1) {
						$state.go("main.projectInfo", {
							Id: id
						})
					} else {
						$state.go("main.newprojectInfo", {
							Id: id
						})
					}

				}
			}
			if(!data["list"]) {
				$scope.page.rongcuo = true
			} else {
				$scope.page.rongcuo = false
				$scope.collection = data["list"]
			}
		})
		setTimeout(function() {
			//滑动删除
			for(var i = 0; i < $(".shopCarMove").length; i++) {
				$(".shopCarMove").eq(i).attr("dataIndex", i);
			}
			shopCarRemove('.shopCarMove');

			function shopCarRemove(box) {
				var boxList = $(box);
				var boxHeight = boxList.outerHeight();
				var btnList = null;
				var btnWidth = null;
				boxList.on("touchstart", function(e) {
					btnList = $('.shopCarDelete');
					btnWidth = -btnList.outerWidth();
					this.startX = e.originalEvent.targetTouches[0].clientX;
					this.startY = e.originalEvent.targetTouches[0].clientY;
				});
				boxList.on("touchend", function(e) {
					var dataIndex = $(this).attr("dataIndex");
					this.MissX = this.startX - e.originalEvent.changedTouches[0].clientX;
					this.MissY = this.startY - e.originalEvent.changedTouches[0].clientY;
					if(Math.abs(this.MissY) < boxHeight && this.MissX > 25) {
						btnList.eq(dataIndex).stop(true, true).animate({
							"right": btnWidth
						}, 80);
						$(this).stop(true, true).animate({
							"right": -btnWidth
						}, 80);
						//				$(this).parent().siblings().find(".shopCarMove").stop(true,true).animate({"right":0},250);
						//				$(this).parent().siblings().find(".shopCarDelete").stop(true,true).animate({"right":btnWidth},250);
					} else if(Math.abs(this.MissY) < boxHeight && this.MissX < -25) {
						btnList.eq(dataIndex).stop(true, true).animate({
							"right": btnWidth
						}, 80);
						$(this).stop(true, true).animate({
							"right": "0px"
						}, 80);
					}
				});
				//点击删除
				$(".shopCarDelete").click(function() {
					var shopCarlistLength = $(this).parents(".footprint_list").find(".order_list_com").length; //每个商铺商品的长度
					if(shopCarlistLength > 1) {
						$(this).parent().parent().remove();
					} else {
						$(this).parents(".footprint_list").remove();
					}
					if($(".order_list_com").length == 0) {
						$scope.page.rongcuo = true;
					}
					var delsku = $(this).attr("sku")
					$http({
						method: 'post',
						url: '' + $rootScope.Location + 'Member/del_collect',
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						data: {
							user_Id: localStorage.getItem("user_ID"),
							token: localStorage.getItem("token"),
							collect_id: "," + delsku
						},
					}).success(function(data) {
						console.log(data)
					})
				})
			}
		}, 1000)
	}])
	//我的团/我的参团列表页面
app.controller("tuxedo", ["$scope", "$stateParams", "$rootScope", "$state", "$http", function($scope, $stateParams, $rootScope, $state, $http) {
		$rootScope.page.showfooter = true;
		$rootScope.page.footer = 'mine';
		if($stateParams.is_p == 1) {
			$scope.mytuan = true
			$scope.myjointuan = false
			$http({
				method: 'post',
				url: '' + $rootScope.Location + 'Regiment/group',
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				data: {
					user_Id: localStorage.getItem("user_ID"),
					token: localStorage.getItem("token"),
				},
			}).success(function(data) {
				console.log(data)
				$rootScope.login(data)
				$scope.list = data["list"]
				$scope.togroupInfo = function(id) {
					$state.go("main.groupInfo", {
						Id: id
					})
				}
			})
		} else {
			$scope.mytuan = false
			$scope.myjointuan = true
			$http({
				method: 'post',
				url: '' + $rootScope.Location + 'Regiment/Regiment',
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				data: {
					user_Id: localStorage.getItem("user_ID"),
					token: localStorage.getItem("token"),
				},
			}).success(function(data) {
				console.log(data)
				$scope.list = data["list"]
			})
		}
	}])
	//我的团详情页面
app.controller("groupInfo", ["$scope", "$stateParams", "$rootScope", "$state", "$http", function($scope, $stateParams, $rootScope, $state, $http) {
		$rootScope.page.showfooter = true;
		$rootScope.page.footer = 'mine';
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Regiment/detail',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token"),
				Id: $stateParams.Id
			},
		}).success(function(data) {
			console.log(data)
			$scope.list = data["list"]
			$scope.people = data["list"]["people"]
			$scope.is_cut = data["list"]["is_cut"]
			$(".icon-x").click(function() {
				$(".order_del").hide()
			})
			$scope.confirm = function(is_click, order_id) {
				if(is_click == 0) {

				} else {
					$(".order_del").show()
					$http({
						method: 'post',
						url: '' + $rootScope.Location + 'Regiment/clicks',
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						data: {
							user_Id: localStorage.getItem("user_ID"),
							token: localStorage.getItem("token"),
							order_Id: order_id
						},
					}).success(function(data) {
						$scope.memberInfo = data["list"]
						$(".true").click(function() {
							$http({
								method: 'post',
								url: '' + $rootScope.Location + 'Regiment/submits',
								headers: {
									'Content-Type': 'application/x-www-form-urlencoded'
								},
								data: {
									user_Id: localStorage.getItem("user_ID"),
									token: localStorage.getItem("token"),
									order_Id: order_id,
									content: $(".textArea").val(),
									type: 1
								},
							}).success(function(data) {
								$(".order_del").hide()
								location.reload()
							})
						})
						$(".false").click(function() {
							$http({
								method: 'post',
								url: '' + $rootScope.Location + 'Regiment/submits',
								headers: {
									'Content-Type': 'application/x-www-form-urlencoded'
								},
								data: {
									user_Id: localStorage.getItem("user_ID"),
									token: localStorage.getItem("token"),
									order_Id: order_id,
									content: $(".textArea").val(),
									type: 2
								},
							}).success(function(data) {
								$(".order_del").hide()
								location.reload()
							})
						})
					})
				}
			}
		})
	}])
	//个人资料
app.controller("personal", ["$scope", "$rootScope", "$state", "$http", function($scope, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'mine';
	$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Member/myinfo',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token"),
			},
		}).success(function(data) {
			console.log(data)
			$scope.nickname = data["list"]["nickname"] //姓名
			$scope.phone = data["list"]["mobile"] //手机号
			$scope.avatar = data["list"]["avatar"] //头像
			$scope.sex = data["list"]["sex"] //性别
			$scope.age = data["list"]["age"] //年龄
			$scope.member_approve = data["list"]["member_approve"]
			load()
			function drawBeauty(beauty) {
				var mycv = document.getElementById("cvs");
				var myctx = mycv.getContext("2d");
				myctx.drawImage(beauty, 0, 0,100,100);
			}

			function load() { 
				var beauty = new Image();
				beauty.src = data["list"]["avatar"]
				if(beauty.complete) {
					drawBeauty(beauty);
				} else {
					beauty.onload = function() {
						drawBeauty(beauty);
					};
					beauty.onerror = function() {
//						window.alert('美女加载失败，请重试');
					};
				};
			} //load
			if(document.all) {
				window.attachEvent('onload', load);
			} else {
				window.addEventListener('load', load, false);
			}
		})
		//修改用户头像
		//	function chooseImg() {
		//		var Li = ""
		//		plus.gallery.pick(
		//			function(path) {
		//				alert(path)
		//				$(".head_img").attr("src", path)
		//				var task = null;
		//				task = plus.uploader.createUpload(
		//					"http://demo.tl178.cn/Member/update_head", {
		//						method: "POST"
		//					},
		//					function(t, status) {
		//						if(status == 200) {
		//							//模拟上传完之后
		//							plus.nativeUI.toast("头像修改成功");
		//						} else {
		//							plus.nativeUI.toast("上传失败" + status);
		//						}
		//					}
		//				);
		//				task.addFile(path, {
		//					key: "fileData"
		//				});
		//				task.addData("token", localStorage.getItem("token"))
		//				task.addData("user_Id", localStorage.getItem("user_ID"))
		//				task.start();
		//			},
		//			function(e) {
		//				plus.nativeUI.toast("取消选择图片")
		//			}, {
		//				filter: "image"
		//			}
		//		)
		//	}
	$scope.chooseImg = function() {
		//		chooseImg()
		//获取上传按钮
		var input1 = document.getElementById("upload");

		if(typeof FileReader === 'undefined') {
			//result.innerHTML = "抱歉，你的浏览器不支持 FileReader"; 
			input1.setAttribute('disabled', 'disabled');
		} else {
			input1.addEventListener('change', readFile, false);
//			input1.addEventListener('change',function (e){
//				console.log(this.files);//上传的文件列表
//			},false); 
		}

		function readFile() {
			var file = this.files[0]; //获取上传文件列表中第一个文件
			if(!/image\/\w+/.test(file.type)) {
				//图片文件的type值为image/png或image/jpg
				alert("文件必须为图片！");
				return false;
			}
			// console.log(file);
			var reader = new FileReader(); //实例一个文件对象
			reader.readAsDataURL(file); //把上传的文件转换成url
			//当文件读取成功便可以调取上传的接口
			reader.onload = function(e) {
//				 console.log(this.result);//文件路径
//				 console.log(e.target.result);//文件路径
				var data = e.target.result.split(',');
				var tp = (file.type == 'image/png') ? 'png' : 'jpg';
//				console.log(data)
				var imgUrl = data[0]+","+data[1]; //图片的url，去掉(data:image/png;base64,)
				//需要上传到服务器的在这里可以进行ajax请求
//				console.log(imgUrl)
				$http({
					method: 'post',
					url: '' + $rootScope.Location + 'Member/update_head',
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						user_Id: localStorage.getItem("user_ID"),
						token: localStorage.getItem("token"),
						fileData:imgUrl
					},
				}).success(function(data) {
					console.log(data)
				})			
				// console.log(imgUrl);
				// 创建一个 Image 对象 
				//		var image = new Image();
				// 创建一个 Image 对象 
				// image.src = imgUrl;
				//		image.src = e.target.result;
				//		image.onload = function(){
				//			document.body.appendChild(image);
				//		}
				var image = new Image();
				// 设置src属性 
				image.src = e.target.result;
				var max = 100;
				// 绑定load事件处理器，加载完成后执行，避免同步问题
				image.onload = function() {
					// 获取 canvas DOM 对象 
					var canvas = document.getElementById("cvs");
					// 如果高度超标 宽度等比例缩放 *= 
					/*if(image.height > max) {
						image.width *= max / image.height; 
						image.height = max;
					} */
					// 获取 canvas的 2d 环境对象, 
					var ctx = canvas.getContext("2d");
					// canvas清屏 
					ctx.clearRect(0, 0, canvas.width, canvas.height);
					// 重置canvas宽高
					/*canvas.width = image.width;
					canvas.height = image.height;
					if (canvas.width>max) {canvas.width = max;}*/
					// 将图像绘制到canvas上
					// ctx.drawImage(image, 0, 0, image.width, image.height);
					ctx.drawImage(image, 0, 0, 100, 100);
					// 注意，此时image没有加入到dom之中
				};
			}
		};
	}

	$scope.gosetloginpsd = function() { //修改登陆密码
			$(".order_del1").show()
			$(".false").click(function() {
				$(".order_del1").hide()
			})
			$(".true").click(function() {
				$http({
					method: 'post',
					url: '' + $rootScope.Location + 'Member/confirm_pwd',
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						user_Id: localStorage.getItem("user_ID"),
						token: localStorage.getItem("token"),
						password: $(".inp_psd").val()
					},
				}).success(function(data) {
					if(data["status"] == 0) {
						$(".addressdialog").show();
						$(".addressdialog").html(data["message"]);
						$(".addressdialog").fadeOut(1200);
						//					plus.nativeUI.toast( data["message"]);
					}
					if(data["status"] == 1) {
						$state.go("main.setloginpsd")
					}
				})
			})
		}
		//退出登录
	$scope.loginOut = function() {
		$(".order_del2").show();
		$(".yes").click(function() {
			$(".order_del2").hide();
			$http({
				method: 'post',
				url: '' + $rootScope.Location + 'login/login_out',
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				data: {
					user_Id: localStorage.getItem("user_ID")
				},
			}).success(function(data) {
				if(data["status"] == 1) {
					localStorage.setItem("user_ID", '')
					localStorage.setItem("token", '')
					$state.go("main.mine")
				}
			})
		})
		$(".no").click(function() {
			$(".order_del2").hide();
		})
	}

}])

app.controller("Real-name", ["$scope", "$rootScope", "$state", "$http", function($scope, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'mine';
	$(".icon-xiangji").click(function() {
//		chooseImg()
				//获取上传按钮
		var input1 = document.getElementById("upload");

		if(typeof FileReader === 'undefined') {
			//result.innerHTML = "抱歉，你的浏览器不支持 FileReader"; 
			input1.setAttribute('disabled', 'disabled');
		} else {
			input1.addEventListener('change', readFile, false);
			input1.addEventListener('change',function (e){
				console.log(this.files);//上传的文件列表
			},false); 
		}

		function readFile() {
			var file = this.files[0]; //获取上传文件列表中第一个文件
			if(!/image\/\w+/.test(file.type)) {
				//图片文件的type值为image/png或image/jpg
				alert("文件必须为图片！");
				return false;
			}
			// console.log(file);
			var reader = new FileReader(); //实例一个文件对象
			reader.readAsDataURL(file); //把上传的文件转换成url
			//当文件读取成功便可以调取上传的接口
			reader.onload = function(e) {
//				 console.log(this.result);//文件路径
//				 console.log(e.target.result);//文件路径
				var data = e.target.result.split(',');
				var tp = (file.type == 'image/png') ? 'png' : 'jpg';
//				console.log(data)
				var imgUrl = data[0]+","+data[1]; //图片的url，去掉(data:image/png;base64,)
				localStorage.setItem("imgUrl",imgUrl)
				//需要上传到服务器的在这里可以进行ajax请求
//				console.log(imgUrl)
				// console.log(imgUrl);
				// 创建一个 Image 对象 
				//		var image = new Image();
				// 创建一个 Image 对象 
				// image.src = imgUrl;
				//		image.src = e.target.result;
				//		image.onload = function(){
				//			document.body.appendChild(image);
				//		}
				var image = new Image();
				// 设置src属性 
				image.src = e.target.result;
				var max = 150;
				// 绑定load事件处理器，加载完成后执行，避免同步问题
				image.onload = function() {
					// 获取 canvas DOM 对象 
					var canvas = document.getElementById("cvs");
					// 如果高度超标 宽度等比例缩放 *= 
					/*if(image.height > max) {
						image.width *= max / image.height; 
						image.height = max;
					} */
					// 获取 canvas的 2d 环境对象, 
					var ctx = canvas.getContext("2d");
					// canvas清屏 
					ctx.clearRect(0, 0, canvas.width, canvas.height);
					// 重置canvas宽高
					/*canvas.width = image.width;
					canvas.height = image.height;
					if (canvas.width>max) {canvas.width = max;}*/
					// 将图像绘制到canvas上
					// ctx.drawImage(image, 0, 0, image.width, image.height);
					ctx.drawImage(image, 0, 0, 150, 150);
					// 注意，此时image没有加入到dom之中
				};
			}
		};
	})
	$scope.btnIDcard = function() {
		var IDcard = $(".id_card").val();
		var Name = $(".nickname").val();
		var card_img = localStorage.getItem("IDcard")
		if(!Name) {
//			plus.nativeUI.toast("请输入您的真实姓名")
			$(".addressdialog").show();
			$(".addressdialog").html("请输入您的真实姓名");
			$(".addressdialog").fadeOut(1200);
		} else {
			if(!IDcard) {
//				plus.nativeUI.toast("请输入您的身份证号")
				$(".addressdialog").show();
				$(".addressdialog").html("请输入您的身份证号");
				$(".addressdialog").fadeOut(1200);
			} else {
				var reg = new RegExp(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/);
				if(reg.test(IDcard) === false) {
//					plus.nativeUI.toast("身份证输入不合法");
				$(".addressdialog").show();
				$(".addressdialog").html("身份证输入不合法");
				$(".addressdialog").fadeOut(1200);
					return false;
				} else {
					
				$http({
					method: 'post',
					url: '' + $rootScope.Location + 'Member/member_approve',
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						user_Id: localStorage.getItem("user_ID"),
						token: localStorage.getItem("token"),
						card:IDcard,
						name:Name,
						fileData:localStorage.getItem("imgUrl")
					},
					}).success(function(data) {
						console.log(data)
					})			
//					var task = null;
//					plus.nativeUI.showWaiting("上传中...");
//					task = plus.uploader.createUpload(
//						$rootScope.Location + "Member/member_approve", {
//							method: "POST"
//						},
//						function(t, status) {
//							if(status == 200) {
//								//模拟上传完之后
//								var res = angular.fromJson(t.responseText)
//									//								alert("上传成功: " + t.responseText);
//								if(res["status"] == 1) {
//									plus.nativeUI.toast("上传成功！")
//									plus.nativeUI.closeWaiting();
//									$state.go("main.personal")
//								} else {
//									plus.nativeUI.toast(res["message"])
//									plus.nativeUI.closeWaiting();
//								}
//							} else {
//								plus.nativeUI.closeWaiting();
//								alert("上传失败" + status);
//							}
//						}
//					);
//					task.addFile(card_img, {
//						key: "fileData"
//					})
//					task.addData("token", localStorage.getItem("token"))
//					task.addData("user_Id", localStorage.getItem("user_ID"))
//					task.addData("card", IDcard)
//					task.addData("name", Name)
//					task.start();
			
				}
			}
		}

	}

//	function chooseImg() { 
//		var cmr = plus.camera.getCamera();
//		var res = cmr.supportedImageResolutions[0];
//		var fmt = cmr.supportedImageFormats[0];
//		cmr.captureImage(function(p) {
//				plus.io.resolveLocalFileSystemURL(p, function(entry) {
//					//          	alert("真实路径："+entry.fullPath);  
//					zipImg(entry.fullPath, 20)
//					$(".card_right").html("<img src='" + entry.fullPath + "'/>")
//				}, function(e) {
//					alert(e.message);
//				});
//			},
//			function(error) {
//				alert("Capture image failed: " + error.message);
//			}, {
//				resolution: res,
//				format: fmt,
//				filename: "_doc/camera/"
//			}
//		);
//	}

//	function zipImg(imgFile, quality) {
//		var fild = []
//		plus.zip.compressImage({
//				src: imgFile, //原始路径
//				dst: imgFile, //压缩后的路径
//				quality: quality, //图片质量
//				overwrite: true //是否替换
//			},
//			function(e) {
//				localStorage.setItem("IDcard", e.target)
//					//uploadImg(imgFile,event)
//			},
//			function(error) {
//				alert("error")
//			});
//	}
}])

//我的消息
app.controller("myNews", ["$scope", "$rootScope", "$state", "$http", function($scope, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'mine';
	$scope.page.show = true
	$scope.page.hide = false
	$scope.pageshow = function() {
		$scope.page.hide = false
		$scope.page.show = true
	}
	$scope.pagehide = function() {
		$scope.page.hide = true
		$scope.page.show = false
	}
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Message/user_message',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token"),
		},
	}).success(function(data) {
		console.log(data)
		$scope.message = data["list"]
		$scope.readall = function(id) {
			$state.go("main.myNewsinfo", {
				Id: id
			})
		}
		if(!data["list"]["user_message"] || data["list"]["user_message"].length == 0) {
			$scope.page.rongcuo = true
		} else {
			$scope.page.rongcuo = false
		}
		if(!data["list"]["message"] || data["list"]["message"].length == 0) {
			$scope.page.rongcuo2 = true
		} else {
			$scope.page.rongcuo2 = false
		}
	})
}])

app.controller("myNewsinfo", ["$scope", "$stateParams", "$rootScope", "$state", "$http", function($scope, $stateParams, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'mine';
	$rootScope.page.goshow = true
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Message/look_message',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token"),
			Id: $stateParams.Id
		},
	}).success(function(data) {
		console.log(data)
		$rootScope.page.goshow = false
		$scope.list = data["list"]
	})
}])

app.controller("qrcode", ["$scope", "$rootScope", "$state", "$http", function($scope, $rootScope, $state, $http) {
	//		$rootScope.page.footer = 'mine';
	$rootScope.page.showfooter = false;
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Member/my_code',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token"),
		}
	}).success(function(data) {
		console.log(data)
		$rootScope.login(data)
		$scope.src = data["list"]["my_code"]
	})
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Member/my_image',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token"),
		}
	}).success(function(data) {
		$scope.member_img = data["list"]["avatar"]
		$scope.member_name = data["list"]["nickname"]
	})
}])